Artificial intelligence in the post-deep learning era
computer notes - Data Structures - 9
1. Class No.09 Data Structures http://ecomputernotes.com
2. Memory Organization Code Static data Stack Heap Process 1 (browser) Process 3 (word) Process 4 (excel) Windows OS Process 2 (dev-c++) http://ecomputernotes.com
3.
4.
5. Queue Operations Enqueue(X) – place X at the rear of the queue. Dequeue() -- remove the front element and return it. Front() -- return front element without removing it. IsEmpty() -- return TRUE if queue is empty, FALSE otherwise http://ecomputernotes.com
6.
7.
8.
9.
10. Implementing Queue int dequeue() { int x = front->get(); Node* p = front; front = front->getNext(); delete p; return x; } void enqueue(int x) { Node* newNode = new Node(); newNode->set(x); newNode->setNext(NULL); rear->setNext(newNode); rear = newNode; } http://ecomputernotes.com
11. Implementing Queue int front() { return front->get(); } int isEmpty() { return ( front == NULL ); } http://ecomputernotes.com
12.
13. Queue using Array front 2 5 7 1 rear 6 5 7 0 0 1 3 2 4 front 1 7 5 2 3 rear http://ecomputernotes.com
14. Queue using Array front 2 5 7 1 rear 6 5 7 0 0 1 3 2 4 front 1 7 5 2 4 rear enqueue(6) 6 6 http://ecomputernotes.com